package cn.hengzhu.main_manager.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.hengzhu.main_manager.repository.dao.OperationLogRecordMapper;
import cn.hengzhu.main_manager.repository.domain.OperationLogRecord;
import cn.hengzhu.main_manager.repository.param.OperationListParam;
import cn.hengzhu.main_manager.utils.LayUiResultJson;
import cn.hengzhu.main_manager.utils.ann.MoblieUrl;


/**
 * @author 刘成
 * @since 2018年7月13日
 * 操作日志
 */
@Controller
@RequestMapping("/operation")
public class OperationController {
	@Autowired
	private OperationLogRecordMapper  operationLogRecordMapper;
	
	@Autowired
	private HttpServletRequest request;
	
	@MoblieUrl
	@RequestMapping("/index")
	public String getOperationPage(){
		return request.getAttribute("moblie")+"operationLog";
	}
	
	
	@RequestMapping("/list")
	@ResponseBody
	public LayUiResultJson<OperationLogRecord> getOperationList(OperationListParam param){
		String keys = param.getKeys();
		if(StringUtils.isNotBlank(keys)){
			keys="%"+keys+"%";
			param.setKeys(keys);
		}
		PageHelper.startPage(param.getPage(), param.getLimit(),true);
		List<OperationLogRecord> list=operationLogRecordMapper.getAll(param);
		PageInfo<OperationLogRecord> pageInfo =new PageInfo<>(list);
		long count = pageInfo.getTotal();
		LayUiResultJson<OperationLogRecord> result = new LayUiResultJson<>(count, list);
		return result;
	}
}











